$(document).ready(function() {
    // 优化手风琴切换时的滚动
    $('.accordion-button').on('click', function() {
        if (window.innerWidth < 768) {
            const headerOffset = 70; // 导航栏高度
            const elementPosition = $(this).offset().top;
            const offsetPosition = elementPosition - headerOffset;

            window.scrollTo({
                top: offsetPosition,
                behavior: "smooth"
            });
        }
    });

    // 图片加载优化
    $('img').on('error', function() {
        $(this).attr('src', 'img/bg.jpg');
    });

    // 全景按钮点击效果
    $('.panorama-btn').on('click', function() {
        const $container = $(this).closest('.panorama-container');
        $container.toggleClass('expanded');
        
        if ($container.hasClass('expanded')) {
            $(this).text('关闭全景');
        } else {
            $(this).text('点击查看全景');
        }
    });

    // 加载更多景点按钮
    let currentSceneries = 5;
    const totalSceneries = $('.accordion-item').length;
    
    $('#loadMoreSceneries').on('click', function() {
        const $hiddenSceneries = $('.accordion-item:hidden');
        const nextSceneries = Math.min(3, $hiddenSceneries.length);
        
        $hiddenSceneries.slice(0, nextSceneries).slideDown();
        
        currentSceneries += nextSceneries;
        if (currentSceneries >= totalSceneries) {
            $(this).hide();
        }
    });
}); 